#include "CoordTransformer.h"



CoordTransformer::CoordTransformer()
{
	m_pj_utm = pj_init_plus("+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs");
	m_pj_latlong = pj_init_plus("+proj=latlong +ellps=WGS84");
}

void CoordTransformer::transformCoordsFromLatLong(double inLat, double inLong, double& outX, double& outY)
{
	double longi = inLong * DEG_TO_RAD;
	double lat = inLat * DEG_TO_RAD;
	
	int p = pj_transform(m_pj_latlong, m_pj_utm, 1, 1, &lat, &longi, NULL);
	outX = lat;
	outY = longi;
}

void CoordTransformer::transformCoordsToLatLong( double inX, double inY, double& outLat, double& outLong )
{
	double x = inX;
	double y = inY;

	int p = pj_transform(m_pj_utm, m_pj_latlong, 1, 1, &x, &y, NULL);
	outLat = x * RAD_TO_DEG;
	outLong = y * RAD_TO_DEG;
}
